package com.lancoo.ccas52.util;


import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;

/**
 * @description: TODO
 * @author: bo
 * @date: 2022/8/25 11:54
 * @version: 1.0
 */
public class MD5Util {


    public static final String key="";


    public static String MD5encrypt(String plainText){

        return DigestUtils.md5Hex(plainText + key);
    }

    public static String MD5encryptRevs(String plainText){

        return StringUtils.reverse(DigestUtils.md5Hex(plainText + key));
    }

    /**
     * @param plainText: 明文
     * @param ciphertext: 密文
     * @return Boolean
     * @description authorization是sysId的MD5加密+反转
     */
    public static Boolean reverseSequenceCheck(String plainText , String ciphertext){

        return StringUtils.reverse(MD5encrypt(plainText)).equalsIgnoreCase(ciphertext);
    }

    public static void main(String[] args) {
        System.out.println(MD5encryptRevs("E31"));
    }
}
